package com.ling.common.library.view

import android.annotation.SuppressLint
import android.content.Context
import android.graphics.Canvas
import android.util.AttributeSet
import android.view.View

/**
 * @author Ling
 * @date 2024/1/5 16:37
 * @des 顶部状态栏高度
 */
class StatusBarSpaceView : View{

    private var statusHeight = 0

    constructor(context: Context?) : this(context , null)
    constructor(context: Context?, attrs: AttributeSet?) : this(context, attrs , 0)
    @SuppressLint("DiscouragedApi", "InternalInsetResource")
    constructor(context: Context?, attrs: AttributeSet?, defStyleAttr: Int) : super(context, attrs, defStyleAttr){
        val resourceId = resources.getIdentifier("status_bar_height", "dimen", "android")
        if (resourceId > 0) {
            statusHeight = resources.getDimensionPixelOffset(resourceId)
        }
    }

    override fun onDraw(canvas: Canvas) {

    }

    override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) {
        setMeasuredDimension(0 , statusHeight)
    }
}